
<link rel="stylesheet" type="text/css" href="/public/static/css/index.css" />
<script src="/public/static/js/synchro.js"></script>
<{include file="tpl/filter.tpl"}>
<div style="margin-bottom: 10px;">	
	<input class="label-success pull-left" type="checkbox" id="all" />&nbsp;<span id="aa">全选</span>		
	<a href="javascript:;" id="version_update_batch" name="version_update_batch" class="btn" style="margin-right: 5px;" data-url="?r=serverOps/setVersionTime">定时版本更新</a>
</div>

<{include file="tpl/grid.tpl"}>
	

<script>
	    $(document).on('click','a[name="version_update_one"]',function(){
	    	var ids = $(this).attr('data-id'); 
            version_update_one(ids);      	
        }); 
        
        
        $('a[name="version_update_batch"]').click(function(){
        	var arr = new Array();
            $("input[name='id']:checkbox[checked]").each(function(i){
                arr[i] = $(this).val();
            });
            var ids = arr.join(",");
            //console.log(ids);
            //return false;
            if(ids == ""){
            	layer.msg('请先选择要操作的数据！', {icon: 2,time: 3000});
            	return false;
            }
            version_update_one(ids);
        });
        
        function version_update_one(ids){       	                   
            var data_url = $('a[name="version_update_batch"]').attr('data-url');
            var g = $("input[name='g']").val();
            
            var url = data_url+'&g='+g;
    		layer.open({
    		    skin: 'layui-layer-molv'
    		    ,btn: ['取消', '确定']
    			,type: 2
    			,area: ['350px', '450px']
    			,title:'设置版本更新时间'
    			,content: url
    			,yes: function(index, layero){
                   //按钮【按钮一】的回调
                   layer.close(index);
                   
                }
                ,btn2: function(index, layero){
                   //按钮【按钮二】的回调
                    var iframeWin = window["layui-layer-iframe" + index];
                    var arr = iframeWin.callbackdata();
                    console.log(arr);
                    if(arr[0] == ''){
                   	   layer.msg('请设置版本更新时间', {icon: 2,time: 3000});
                   	   return false;
                    }
                    
                    if(arr[1] == ''){
                   	   layer.msg('请设置更新包名', {icon: 2,time: 3000});
                   	   return false;
                    }
                    
                    var version_update_time = arr[0];
                    var update_packet = arr[1];
                   
                    $.ajax({
                   	    type : 'POST',
    		            url : url,
			            data : {'ids':ids,'version_update_time':version_update_time,'update_packet':update_packet},
			            dataType :'JSON',
			            success : function(res){
				            if(res.status == 1){
				    	        layer.alert('操作完成', {
				        	      skin: 'layui-layer-molv' //样式类名
						          ,closeBtn: 0
					            }, function(){
						          window.location.reload();
					            }); 
				            }else{
					           layer.alert(res.msg, {icon: 2, skin: 'layui-layer-molv'});
					           return false;
				            }
			            }
		            });	

                   //return false 开启该代码可禁止点击该按钮关闭
                },cancel: function(){ 
                   //右上角关闭回调
                   //return false 开启该代码可禁止点击该按钮关闭
                }
    		});
        }
</script>

